﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class ChatsQuestion : System.Web.UI.Page
{
	private PX.Expert.ExpertComponent clsExpertComp = new PX.Expert.ExpertComponent();
	private PX.Chat.ChatComponent clsChatComp = new PX.Chat.ChatComponent();
	private PX.Config clsConfig = new PX.Config();
	private PX.OnLine.OnLineComponent clsOnLineComp = new PX.OnLine.OnLineComponent();

	/// <summary>
	/// 提问者Session
	/// </summary>
	private string strQuestionSession = "";

	protected override void OnInit(EventArgs e)
	{
		base.OnInit(e);

		idBody.Attributes.Add("onload", "goButtom('" + pPlatForm.ClientID.ToString() + "')");

		strQuestionSession = Session.SessionID.ToString();
	}

	protected void Page_Load(object sender, EventArgs e)
	{
		ShowChat();
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 显示交流记录
	/// </summary>
	private void ShowChat()
	{
		List<PX.Chat.Chat> list = new List<PX.Chat.Chat>();

		list = clsChatComp.Query(strQuestionSession);

		pPlatForm.Controls.Clear();

		for (int i = 0; i < list.Count; i++)
		{

			TextBox txtChat = new TextBox();
			Panel pOneChat = new Panel();
			Label labTitle = new Label();
			PX.Expert.Expert clsExpert = new PX.Expert.Expert();

			labTitle.CssClass = "Public_OneChatTitle";
			pOneChat.CssClass = "Public_OneChat";
			txtChat.CssClass = "Public_OneChatContent";

			try
			{
				clsExpert = clsExpertComp.Query(list[i].ExpertSession);
			}
			catch (Exception ex)
			{
				clsExpert = null;
			}

			if (clsExpert != null)
			{
				if (list[i].QorA == clsConfig.nChat_Question)
				{
					labTitle.Text = "您对“" + clsExpert.Name + "”提问";
				}
				else
				{
					labTitle.Text = "“" + clsExpert.Name + "”回答您";
				}
			}

			pOneChat.Controls.Add(labTitle);

			txtChat.TextMode = TextBoxMode.MultiLine;
			//txtChat.Attributes.Clear();
			//txtChat.Attributes.Add("style", "width:250px;overflow-y:visible;");

			txtChat.Text = list[i].Chats;

			//Literal lit = new Literal();

			//lit.Text = "<textarea style = \"width: 250px; overflow-y: visible;\">"+list[i].Chats+"</textarea>";

			pOneChat.Controls.Add(txtChat);

			pPlatForm.Controls.Add(pOneChat);
		}

		pPlatForm.Attributes.Add("onload", "goButtom('" + pPlatForm.ClientID.ToString() + "')");
	}
	////////////////////////////////////////////////////////////////////////////////////////////////////
}
